package com.simon.singleton;

public class singletondemo {
    public static void main(String[] args) {
        Singleton instance = Singleton.getInstance();
        Singleton instance2 = Singleton.getInstance();
        System.out.println(instance == instance2);//
    }
}
class Singleton{
    //1、构造器私有化
    private Singleton(){}
    //本类内部创建实例对象
    private final static Singleton instance = new Singleton();
    //3、
    public static Singleton getInstance(){
        return instance;
    }
}